home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / hstream / seeheader.c < prev   
Encoding:
C/C++ Source or Header  |  1993-03-25  |  2.9 KB  |  123 lines

  1. /*
  2.  * Copyright (c) 1991 Michael Landy
  3.  *
  4.  * Disclaimer:  No guarantees of performance accompany this software,
  5.  * nor is any responsibility assumed on the part of the authors.  All the
  6.  * software has been tested extensively and every effort has been made to
  7.  * insure its reliability.
  8.  */
  9.  
  10. /*
  11.  * seeheader.c - print the header of a frame sequence
  12.  *
  13.  * Usage:    seeheader [-p] [-a] < frame
  14.  *
  15.  * Load:    cc -o seeheader seeheader.c -lhips
  16.  *
  17.  * Michael Landy - 2/4/82
  18.  * HIPS 2 - msl - 1/6/91
  19.  *
  20.  * The -p option allows seeheader to be used in a pipe, sending the
  21.  * original sequence to the standard output, and the text output to stderr.
  22.  * The -a flag causes entire extended parameter arrays to be printed.  By
  23.  * default at most 5 values are printed. If the -s flag is specified, then
  24.  * per-frame headers are output if the file is a stream file.
  25.  */
  26.  
  27. #include <hipl_format.h>
  28. #include <stdio.h>
  29.  
  30. static Flag_Format flagfmt[] =
  31. {
  32.     {"p",
  33.      {LASTFLAG}, 0,
  34.      {
  35.      {PTBOOLEAN, "FALSE"}, LASTPARAMETER}},
  36.     {"a",
  37.      {LASTFLAG}, 0,
  38.      {
  39.      {PTBOOLEAN, "FALSE"}, LASTPARAMETER}},
  40.     {"s",
  41.      {LASTFLAG}, 0,
  42.      {
  43.      {PTBOOLEAN, "FALSE"}, LASTPARAMETER}},
  44.     LASTFLAG};
  45.  
  46. /*
  47. #define DEBUG
  48. */
  49.  
  50. main(argc, argv)
  51.     int       argc;
  52.     char    **argv;
  53.  
  54. {
  55.     struct header hd;
  56.     int       c, i, skip, pad;
  57.     Boolean   pflag, aflag, sflag;
  58.     Filename  filename;
  59.     FILE     *fp;
  60.  
  61.     Progname = strsave(*argv);
  62.     parseargs(argc, argv, flagfmt, &pflag, &aflag, &sflag, FFONE, &filename);
  63.     fp = hfopenr(filename);
  64.     if (pflag)
  65.     fread_hdr_a(fp, &hd, filename);
  66.     else
  67.     fread_header(fp, &hd, filename);
  68.     fprintf(stderr, "%s", formatheaderc(&hd, aflag));
  69. #ifdef DEBUG
  70.     fprintf(stderr, "after format_header, fp now at: %d \n", (int) ftell(fp));
  71. #endif
  72.     {
  73.     stream_info sinfo;
  74.     sframe_header fhd;
  75.  
  76.     if (sflag) {
  77. #ifdef NEED
  78.         check_stream_header(&hd, FALSE);
  79. #endif
  80.         if (get_sinfo(&sinfo, 0) && sinfo.stream) {
  81.         if (hd.numcolor == 3)
  82.             hd.num_frame /= 3;
  83.         if (sinfo.comp_type == 1)
  84.             hread_jmain_header(fp);
  85. #ifdef DEBUG
  86.         fprintf(stderr, "after read_main header, fp now at: %d \n",
  87.             (int) ftell(fp));
  88. #endif
  89.  
  90.         for (i = 0; i < hd.num_frame; i++) {
  91.             if (sinfo.comp_type == 1 && i > 0)
  92.             hread_jscan_header(fp);
  93. #ifdef DEBUG
  94.             fprintf(stderr, "after read scan header, fp now at: %d \n",
  95.                 (int) ftell(fp));
  96. #endif
  97.             if (read_stream_header(fp, &hd, &fhd, i) == HIPS_ERROR)
  98.             break;
  99.  
  100.             fprintf(stderr, "frame %d, size: %d, time code %d:%d:%d:%d \n",
  101.                 fhd.frame, fhd.size, fhd.tc.hr, fhd.tc.mn,
  102.                 fhd.tc.sc, fhd.tc.fr);
  103.  
  104.             fseek(fp, fhd.size, 1);    /* skip over JPEG data */
  105.         }
  106.         }
  107.     }
  108.     }
  109.     if (!pflag)
  110.     return (0);
  111.     write_header(&hd);
  112.     if (hd.sizeimage) {
  113.     for (i = 0; i < hd.num_frame; i++) {
  114.         fread_image(fp, &hd, i, filename);
  115.         write_image(&hd, i);
  116.     }
  117.     } else {
  118.     while ((c = getc(fp)) != EOF)
  119.         putchar(c);
  120.     }
  121.     return (0);
  122. }
  123.